
#ifndef SVGGRAPHICITEM_H
#define SVGGRAPHICITEM_H

#include <BPolygon2>
#include <BGraphicItem>

using namespace BWE;

class SvgGraphicItem : public BGraphicItem
{
	BOBJECT(SvgGraphicItem);
public:
	SvgGraphicItem(BGraphicItem* parent = 0);
	~SvgGraphicItem();

	void appendPoint(const BPointf& point);
	void insertPoint(int index, const BPointf& point);
	void removePoint(int index);
	void clearPoints();

	int pointCount() const;
	const BPointf& point(int index) const;

	bool stepFill();

private:
	void freshAngle(int pos, BIntArray& indices, BRealArray& angles) const;

protected:
	virtual void paint(BPainter& painter);

	virtual void freshEvent(const BEvent& event);

	virtual void mouseMoveEvent(const BMouseEvent& mouseEvent);

	virtual void mouseClickEvent(const BMouseEvent& mouseEvent);

private:
	mutable bool		_dirty;
	BArray<BPointf>		_points;
	mutable BPointf		_center;
	BRealArray			_angles;
	BIntArray			_indices;
	BArray<BInt>		_trig_indices;
};

#endif
